#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTextEdit>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //设置标题
    this->setWindowTitle("我的记事本");
    //创建菜单栏
    QMenuBar *menubar = this->menuBar();
    //将菜单栏放入窗口中
    this->setMenuBar(menubar);
    //创建菜单
    QMenu* menu1 = new QMenu("文件(&F)");
    QMenu* menu2 = new QMenu("编辑(&E)");
    QMenu* menu3 = new QMenu("构建(&B)");
    QMenu* menuchild = new QMenu("子菜单");
    menubar->addMenu(menu1);
    menu1->addMenu(menuchild);
    menubar->addMenu(menu2);
    menubar->addMenu(menu3);
    //创建菜单项
    QAction* action1 = new QAction("保存");
    QAction* action2 = new QAction("加载");
    action1->setIcon(QIcon(":/save.png"));
    action2->setIcon(QIcon(":/load.png"));
    menuchild->addAction(action1);
    menu1->addSeparator();
    menuchild->addAction(action2);
    connect(action1,&QAction::triggered,this,&MainWindow::handel1);
    connect(action2,&QAction::triggered,this,&MainWindow::handel2);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::handel1()
{
    qDebug() << "handle1";
}

void MainWindow::handel2()
{
    qDebug() << "handle2";
}

